/**
 * 
 */
package fr.toto.triseries;

import java.util.Set;

import com.kokotchy.betaSeriesAPI.model.Episode;
import com.kokotchy.betaSeriesAPI.model.Season;
import com.kokotchy.betaSeriesAPI.model.Show;

import fr.toto.constantes.Query;

/**
 * @author tshepo
 * 
 */
public class ExecQuery implements Runnable {

	Episode episode;
	Show show;
	Query action;

	/**
	 * 
	 */
	public ExecQuery(Episode ep, Query ac) {
		episode = ep;
		action = ac;

	}

	public ExecQuery(Show sh, Query ac) {
		show = sh;
		action = ac;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Runnable#run()
	 */
	@Override
	public void run() {
		switch (action) {
		case SEEN:
			BetaSeriesQuery.setWatched(episode);
			break;
		case DOWNLOADED:
			BetaSeriesQuery.setDownloaded(episode);
			break;
		case ARCHIVE:
			BetaSeriesQuery.setArchived(show, true);
			break;
		case UNARCHIVE:
			BetaSeriesQuery.setArchived(show, false);
			Set<Season> sai = BetaSeriesQuery.getShowsEpisode(show.getUrl());
			for (Season s1 : sai) {
				for (Episode epi : s1.getEpisodes().values()) {
					EpisodesSet.add(epi);
				}
			}
			break;
		}
	}

}
